home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 63.zip
/
BS1 part 63
/
Hisoft Basic AGA v1.04D d2.adf
/
GetFile.bas
< prev
next >
Wrap
BASIC Source File
|
1989-05-17
|
1KB
|
55 lines
' a program showing the use of the ARP File Requestor
' IMPORTANT: will *not* work on versions of the compiler
' prior to 1.04 due to a bug; it will compile but not run correctly
DEFINT a-z
LIBRARY "arp.library"
DECLARE FUNCTION FileRequest&(buffer&) LIBRARY
DECLARE FUNCTION BaseName&(pathptr&) LIBRARY
DECLARE SUB TackOn(path&,file&) LIBRARY
' passed a complete pathname, breaks it up into path/filename
' then calls the ARP selector
' returns -1 if OK, 0 means Cancelled
' changes the parameter if OK selected
FUNCTION GetFile%(fname$,message$)
LOCAL path$,file$,buffer&(6),result&,term%
' split up the pathname as required
path$=SPACE$(80)
LSET path$=fname$+CHR$(0)
file$=SPACE$(40)
result&=BaseName(SADD(path$))
POKEB result&,0 'into path$
term%=result&-SADD(path$)
LSET file$=RIGHT$(fname$,LEN(fname$)-term%)+CHR$(0)
' get the FR_buffer set up and call ARP
buffer&(0)=SADD(message$+CHR$(0))
buffer&(1)=SADD(file$)
buffer&(2)=SADD(path$)
buffer&(3)=0 'window pointer
buffer&(4)=0: buffer&(5)=0: buffer&(6)=0
result&=FileRequest(VARPTR(buffer&(0)))
IF result&=0 THEN
GetFile%=0
ELSE
TackOn SADD(path$),SADD(file$)
fname$=LEFT$(path$,INSTR(path$,CHR$(0))-1)
GetFile%=-1
END IF
END FUNCTION
' example code:
file$="test.bas"
DO
worked=GetFile(file$,"Select File")
PRINT file$
LOOP UNTIL worked=0 'until cancelled